package cn.longwingstech.intelligence.agent.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.longwingstech.intelligence.agent.model.entity.ChatHistory;
import cn.longwingstech.intelligence.agent.service.ChatHistoryService;
import cn.longwingstech.intelligence.agent.mapper.ChatHistoryMapper;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;

/**
* @author a1369
* @description 针对表【chat_history(对话历史)】的数据库操作Service实现
* @createDate 2025-08-04 17:55:51
*/
@Service
public class ChatHistoryServiceImpl extends ServiceImpl<ChatHistoryMapper, ChatHistory>
    implements ChatHistoryService{
    /**
     * 保存user消息
     *
     * @param message
     * @param appid
     */
    @Override
    public void saveUserMessage(String message, Long appid) {
        ChatHistory entity = new ChatHistory();
        entity.setMessage(message);
        entity.setAppid(appid);
        entity.setMessageType("user");
        boolean save = super.save(entity);
        Assert.state(save, "保存失败");
    }

    /**
     * 保存assistant消息
     *
     * @param message
     * @param appid
     */
    @Override
    public void saveAssistantMessage(String message, Long appid) {
        ChatHistory entity = new ChatHistory();
        entity.setMessage(message);
        entity.setAppid(appid);
        entity.setMessageType("assistant");
        boolean save = super.save(entity);
        Assert.state(save, "保存失败");
    }
}




